package com.sb.async;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * Created by wujunzhou on 2017/11/1.
 */
@Configuration
@EnableAsync
public class SpringAsyncConfig {
    private  final Logger logger= LoggerFactory.getLogger(SpringAsyncConfig.class);
    @Bean
    public AsyncTaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setMaxPoolSize(10);
        logger.info("新线程");
        return executor;
    }
}
